package com.crayon2f.test.thread;

import org.junit.Test;

import java.util.concurrent.TimeUnit;

/**
 * Created by feifan.gou@gmail.com on 2021/2/24 11:57.
 */
public class NotifySleepThread {

    @Test
    public void test() throws InterruptedException {

        Thread thread = new Thread(() -> {

            System.out.println("start ====");
            try {
                TimeUnit.SECONDS.sleep(10);
            } catch (InterruptedException e) {

            }
            System.out.println("end ====");
        });

        thread.start();
        TimeUnit.SECONDS.sleep(5);
        Thread.currentThread().interrupt();
        TimeUnit.SECONDS.sleep(5);
        thread.join();
    }
}
